<?php
            


/**
 * 插件的配置项处理，可在此处进行判断并返回数据
 */
if ($_P['wk_call_days']<=0){
    return_msg('微客模式默认打call天数必须大于0');
    die();
}
if(mb_strlen(trim($_P['wk_call_declaration'])) > 80){
    return_msg('微客模式打call宣言长度不超过80字');
    die();
}
if(mb_strlen(trim($_P['wk_show_slogan'])) > 13){
    return_msg('微客模式打call口号长度不超过13字');
    die();
}
$tconfig = '';
if(intval($_P['wk_template_id']) > 0 && $_P['wk_template_id'] != $_P['wk_old_template_id']){
    require_once YX_PLUGIN_CORE . 'inc/plugin_model.php';
    require_once get_path('plugin/weike/core/model.php');
    $template = \WeikeModel::getTemplateInfo($system,intval($_P['wk_template_id']));
//    var_dump($template);die();
    if (!empty($template['config'])){
        $tconfig = $template['config'];
    }
}
//if (empty($_P['wk_call_declaration'])){
//    return_msg('微客模式默认打call宣言不能为空');
//    die();
//}
//var_dump($_P);die();
//if (empty($_P['wk_gift_rules'])){
//    return_msg('微客模式礼物规则不能为空');
//    die();
//}

//if (empty($_P['wk_gift_bags'])){
//    return_msg('微客模式特权礼包内容不能为空');
//    die();
//}

$tempconfig=array(
    'wk_call_days'=>intval($_P['wk_call_days']),//默认打call天数
    'wk_call_declaration'=>trim($_P['wk_call_declaration']),//默认打call宣言
    'wk_call_open'=>intval($_P['wk_call_open']),//是否开启打call
    'wk_call_form_type'=>intval($_P['wk_call_form_type']),//打call收集信息：0不收集 1手机号 2手机号+姓名
    'wk_call_type'=>$_P['wk_call_type']?intval($_P['wk_call_type']):0,//打call模式
    'wk_call_gift_group_id'=>$_P['wk_call_gift_group_id']?intval($_P['wk_call_gift_group_id']):0,//打call礼品
    'wk_gift_open'=>intval($_P['wk_gift_open']),//是否开启打赏礼物
    'wk_gift_form_type'=>intval($_P['wk_gift_form_type']),//打赏收集信息：0不收集 1手机号 2手机号+姓名
    'wk_gift_group_id'=>$_P['wk_gift_group_id']?intval($_P['wk_gift_group_id']):0,//打赏礼物
    'wk_gift_unit'=>trim($_P['wk_gift_unit'])?:'金币',//打赏礼物单位
    'wk_gift_money_give'=>intval($_P['wk_gift_money_give'])?:0,//打赏的钱到哪 0客户 1影楼
    'wk_gift_rules'=>!empty($_P['wk_gift_rules'])?$_P['wk_gift_rules']:[],//礼物规则
    'wk_give_call_button_img'=>isset($tconfig['wk_give_call_button_img'])?tomedia($tconfig['wk_give_call_button_img']):(trim($_P['wk_give_call_button_img'])?tomedia($_P['wk_give_call_button_img']):''),//送礼物广告图片
    'wk_give_gift_ad_img'=>isset($tconfig['wk_give_gift_ad_img'])?tomedia($tconfig['wk_give_gift_ad_img']):(trim($_P['wk_give_gift_ad_img'])?tomedia($_P['wk_give_gift_ad_img']):''),//送礼物广告图片
    'wk_get_gift_ad_img'=>isset($tconfig['wk_get_gift_ad_img'])?tomedia($tconfig['wk_get_gift_ad_img']):(trim($_P['wk_get_gift_ad_img'])?tomedia($_P['wk_get_gift_ad_img']):''),//领取礼包广告图片
    'wk_get_gift_icon'=>isset($tconfig['wk_get_gift_icon'])?tomedia($tconfig['wk_get_gift_icon']):(trim($_P['wk_get_gift_icon'])?tomedia($_P['wk_get_gift_icon']):''),//领取礼包悬浮按钮
    'wk_gift_bag_bg'=>isset($tconfig['wk_gift_bag_bg'])?tomedia($tconfig['wk_gift_bag_bg']):(trim($_P['wk_gift_bag_bg'])?tomedia($_P['wk_gift_bag_bg']):''),//特权礼包背景图
    'wk_gift_bags'=>!empty($_P['wk_gift_bags'])?$_P['wk_gift_bags']:[],//特权礼包内容
    'wk_time_bg'=>isset($tconfig['wk_time_bg'])?tomedia($tconfig['wk_time_bg']):(trim($_P['wk_time_bg'])?tomedia($_P['wk_time_bg']):''),//倒计时背景图
    'wk_buy_limit'=>intval($_P['wk_buy_limit'])?:0,//领取礼包限量配置
    'wk_buy_button_tips'=>trim($_P['wk_buy_button_tips'])?:'',//支付按钮下方提示
    'wk_button_left_text'=>trim($_P['wk_button_left_text'])?:'送Ta礼物',//左侧按钮文字
    'wk_button_left_text_color'=>trim($_P['wk_button_left_text_color'])?:'#ffffff',//左侧按钮文字颜色
    'wk_button_left_bg_color'=>isset($tconfig['wk_button_left_bg_color'])?trim($tconfig['wk_button_left_bg_color']):(trim($_P['wk_button_left_bg_color'])?:'#f36765'),//左侧按钮背景颜色
    'wk_button_right_text'=>trim($_P['wk_button_right_text'])?:'领取礼包',//右侧按钮文字
    'wk_button_right_text_color'=>trim($_P['wk_button_right_text_color'])?:'#ffffff',//右侧按钮文字颜色
    'wk_button_right_bg_color'=>isset($tconfig['wk_button_right_bg_color'])?trim($tconfig['wk_button_right_bg_color']):(trim($_P['wk_button_right_bg_color'])?:'#DC2A21'),//右侧按钮背景颜色
    'wk_button_form_text'=>trim($_P['wk_button_form_text'])?:'立即领取',//表单提交按钮文字
    'wk_button_form_text_color'=>trim($_P['wk_button_form_text_color'])?:'#ffffff',//表单提交文字颜色
    'wk_button_form_bg_color'=>isset($tconfig['wk_button_form_bg_color'])?trim($tconfig['wk_button_form_bg_color']):(trim($_P['wk_button_form_bg_color'])?:'#FF526D'),//表单提交按钮背景颜色
    'wk_content_get_gift_button'=>isset($tconfig['wk_content_get_gift_button'])?tomedia($tconfig['wk_content_get_gift_button']):(trim($_P['wk_content_get_gift_button'])?tomedia($_P['wk_content_get_gift_button']):''),//内容图中button按钮图片
    'wk_content_get_gift_button_width'=>isset($tconfig['wk_content_get_gift_button_width'])?floatval($tconfig['wk_content_get_gift_button_width']):(floatval($_P['wk_content_get_gift_button_width'])?:0),//内容图中button按钮宽
    'wk_content_get_gift_button_top'=>isset($tconfig['wk_content_get_gift_button_top'])?intval($tconfig['wk_content_get_gift_button_top']):(intval($_P['wk_content_get_gift_button_top'])?:0),//内容图中button按钮距离顶部
    'wk_content_get_gift_button_text'=>trim($_P['wk_content_get_gift_button_text'])?:'',//按钮文字
    'wk_show_slogan'=>trim($_P['wk_show_slogan'])?:'',//口号
    'wk_photo_type'=>$_P['wk_photo_type']?intval($_P['wk_photo_type']):0,//客片类型
    'wk_collect_form_title'=>trim($_P['wk_collect_form_title'])?:'',//收集信息标题
    'wk_button_ismy_text'=>trim($_P['wk_button_ismy_text']),//客户自己分享按钮文字
    'wk_button_form_ismy_text'=>trim($_P['wk_button_form_ismy_text']),//客户自己邀请报名文字
    'wk_user_info_bg' => isset($tconfig['wk_user_info_bg'])?tomedia($tconfig['wk_user_info_bg']):(trim($_P['wk_user_info_bg'])?tomedia($_P['wk_user_info_bg']):'https://css2020.yixuan.net/2020css/weike/images/icon11.png'),//客片信息背景图
    'wk_call_left_bg' => isset($tconfig['wk_call_left_bg'])?tomedia($tconfig['wk_call_left_bg']):(trim($_P['wk_call_left_bg'])?tomedia($_P['wk_call_left_bg']):'https://css2020.yixuan.net/2020css/weike/images/icon3_01.png'),//打call宝贝人气
    'wk_call_left_icon' => isset($tconfig['wk_call_left_icon'])?tomedia($tconfig['wk_call_left_icon']):(trim($_P['wk_call_left_icon'])?tomedia($_P['wk_call_left_icon']):'https://css2020.yixuan.net/2020css/weike/images/icon2.png'),//打call宝贝人气图标
    'wk_call_left_help_color' => isset($tconfig['wk_call_left_help_color'])?$tconfig['wk_call_left_help_color']:$_P['wk_call_left_help_color'],//打call宝贝人气内引导文字颜色
    'wk_call_right_help_color' => isset($tconfig['wk_call_right_help_color'])?$tconfig['wk_call_right_help_color']:$_P['wk_call_right_help_color'],//打call解锁礼品内引导文字颜色
    'wk_call_right_bg' => isset($tconfig['wk_call_right_bg'])?tomedia($tconfig['wk_call_right_bg']):(trim($_P['wk_call_right_bg'])?tomedia($_P['wk_call_right_bg']):'https://css2020.yixuan.net/2020css/weike/images/icon16_01.png'),//打call解锁礼品
    'wk_call_right_icon' => isset($tconfig['wk_call_right_icon'])?tomedia($tconfig['wk_call_right_icon']):(trim($_P['wk_call_right_icon'])?tomedia($_P['wk_call_right_icon']):'https://css2020.yixuan.net/2020css/weike/images/icon18.png'),//打call解锁礼品图标
    'wk_call_center_bg' => isset($tconfig['wk_call_center_bg'])?tomedia($tconfig['wk_call_center_bg']):(trim($_P['wk_call_center_bg'])?tomedia($_P['wk_call_center_bg']):'https://css2020.yixuan.net/2020css/weike/images/icon3_hs_02.png'),//打call中间背景
    'wk_call_bottom_bg' => isset($tconfig['wk_call_bottom_bg'])?tomedia($tconfig['wk_call_bottom_bg']):(trim($_P['wk_call_bottom_bg'])?tomedia($_P['wk_call_bottom_bg']):'https://css2020.yixuan.net/2020css/weike/images/icon3_hs_03.png'),//打call底部背景
    'wk_gift_bags_text_color'=>isset($tconfig['wk_gift_bags_text_color'])?trim($tconfig['wk_gift_bags_text_color']):(trim($_P['wk_gift_bags_text_color'])?:'#D63471'),//特权礼包文字颜色
    'wk_theme_color'=>isset($tconfig['wk_theme_color'])?trim($tconfig['wk_theme_color']):(trim($_P['wk_theme_color'])?:'#F7E6EA'),//页面头部标题栏背景颜色与限量领取N张背景颜色
    'wk_worker_call_type'=>$_P['wk_worker_call_type']?intval($_P['wk_worker_call_type']):0,//是否允许员工打call
    'wk_worker_gift_type'=>$_P['wk_worker_gift_type']?intval($_P['wk_worker_gift_type']):0,//是否允许员工打赏
    'wk_photo_show_type'=>$_P['wk_photo_show_type']?intval($_P['wk_photo_show_type']):0,//客片展示形式
    'wk_show_friend_info_type'=>$_P['wk_show_friend_info_type']?intval($_P['wk_show_friend_info_type']):1,//展示好友信息 1头像 2手机号
    'wk_template_id'=>$_P['wk_template_id']?intval($_P['wk_template_id']):0,//微客模版
);
//判断领取礼包限量配置
if ($_P['wk_buy_limit']==0){
    $tempconfig['tuanmode'] = 1;
}elseif ($_P['wk_buy_limit']>0){
    $tempconfig['tuanmode'] = 0;
    $tempconfig['maxcountall'] = (int)$_P['wk_buy_limit']+1;
    $tempconfig['maxcount'] = (int)$_P['wk_buy_limit'];
}
//if (!$_G['isSuperAdmin']){
//    $tempconfig['weike_add'] = $config_old['weike_add'];
//}else{
//    $tempconfig['demo_config1']=intval($_P['demo_config1']);//配置项1
//}
/**
 * 重要：不要忘记执行下方数组合并
 */
$config =array_merge($config,$tempconfig);


